namespace Scenic
{
namespace Renderer
{

class AAPolygonRenderer : public PolygonRenderer
{
	Context *context;
	GLUtesselator *tessObj;
	TessVertexBuffer tessVertexBuffer;
	int color0;
	int color;
	int color2;
	int color8;

	VertexStore *vs;
	VertexStore *addVs;
	VertexStore *subVs;

	TessVertex *triangle[3];
	bool triangleEdge[3];
	bool edgeState;
	int corner;
	double filterLength;
public:
	AAPolygonRenderer(Context *context);
	~AAPolygonRenderer();

	void begin();
	void end();
	void beginContour();
	void endContour();
	void addPoint(double x, double y);

	void edgeFlag(bool edge);
	void combineFunc(double coords[3], struct TessVertex *d[4], 
		float w[4], struct TessVertex **dataOut);
	void vertexFunc(struct TessVertex *data);
private:
	void draw();
	void processTriangle();
	void drawEdge(TessVertex *v1, TessVertex *v2);
	void drawEdge2(TessVertex *v1, TessVertex *v2);
	void addCorner(Double2 p, double sign, double color);
	void createTexture();
};

}
}
